package 第九周.homework;
//Author：☆♢
/*修改pp11.1的解决方案，当异常抛出时捕获它并处理。
处理异常的方式为输出一条适当的信息并继续处理后面的字符串。*/
import java.util.Scanner;
    public class  pp11_2  {
        //Creates an expection object and possible throws it.
        public static void main(String[] args) {
            final int NUM = 20;

            Scanner scan = new Scanner(System.in);
            System.out.println("Enter a string which character numbers Less than" + NUM);
            String string = scan.nextLine();
            try {
                    if (string.length() > NUM)
                    throw new StringTooLongException("The String have too many character.");
                }
                catch (StringTooLongException e){
                    System.out.println("The String have too many character.");
                }
            if (string.substring(string.length() - 4, string.length()).equals("Done"))
                System.out.println("End of the method.");
            }
        }

